package com.company.clientscard.server.domain.locators;

import com.company.clientscard.server.domain.Client;
import com.company.clientscard.server.service.ClientService;
import com.company.clientscard.server.service.Context;
import com.google.web.bindery.requestfactory.shared.Locator;

public class ClientLocator extends Locator<Client, Long> {

	@Override
	public Client create(Class<? extends Client> clazz) {
		return new Client();
	}

	@Override
	public Client find(Class<? extends Client> clazz, Long id) {
        ClientService bean = (ClientService) Context.getContext().getBean("client.service");
        return bean.findById(id);
	}

	@Override
	public Class<Client> getDomainType() {
		// TODO Auto-generated method stub
		return Client.class;
	}

	@Override
	public Long getId(Client domainObject) {
		// TODO Auto-generated method stub
		return domainObject.getId();
	}

	@Override
	public Class<Long> getIdType() {
		// TODO Auto-generated method stub
		return Long.class;
	}

	@Override
	public Object getVersion(Client domainObject) {
		// TODO Auto-generated method stub
		return domainObject.getVersion();
		// return 1L;
	}

}
